package com.m4f.city.utils.table;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.m4f.city.business.domain.ifc.IModelDomain;

public class DataTable<T extends IModelDomain>{
	private Integer page;
	private Integer total;
	private List<TableRow<T>> rows;
	
	public DataTable() {
		this.rows = new ArrayList<TableRow<T>>();
		this.page = 1;
		this.total = 99;
	}
	
	public DataTable(Collection<T> collection) {
		this();
		this.setCollection(collection);
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public List<TableRow<T>> getRows() {
		return rows;
	}

	public void setRows(List<TableRow<T>> rows) {
		this.rows = rows;
	}
	
	public void setCollection(Collection<T> collection) {
		for(T t : collection) {
			this.rows.add(new TableRow<T>(t));
		}
	}
}
